/*
 * @Descripttion: 商品路由文件
 * @version: 
 * @Author: 一氧化二氢
 * @Date: 2022-01-02 20:25:38
 * @lastEditorTime: Do no edit
 */
const Router = require('koa-router')

const { auth, hadAdminPermission, } = require('../middleware/auth.middleware')
const { checkFileType, validator } = require('../middleware/goods.middleware')
const { upload, create, update, remove, restore,findAll } = require("../controller/goods.controller")
const router = new Router({ prefix: "/goods" })

//上传商品图片接口
router.post('/upload', auth, hadAdminPermission, checkFileType, upload)

//发布商品接口
router.post('/', auth, hadAdminPermission, validator, create)

//修改商品接口
router.put('/:id', auth, hadAdminPermission, validator, update)

//删除商品接口
// router.delete('/:id', auth, hadAdminPermission, remove)

//下架商品接口
router.post('/:id/off', auth, hadAdminPermission, remove)
//上架商品接口
router.post('/:id/on', auth, hadAdminPermission, restore)
//获取商品列表接口
router.get('/',findAll)
module.exports = router